package org.john.tool;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;


public class SqlGenerator {

    /**
     * @param args
     */
    public static void main(String[] args) {
        List<String> list = new ArrayList<String>();
        list.add("aa");
        list.add("bb");
        list.add("cc");
        System.out.println(list.toString());
        StringBuilder sb = new StringBuilder("a");
        sb.append("bb").append("cc");
        System.out.println(sb);
        String encoding = "GBK";
        File sqlFile = new File("/home/adsame/文档/优酷需求/youku_pause.txt");
        File newSqlFile = new File("/home/adsame/文档/优酷需求/youku_pause_new.txt");
        File outFile = new File("/home/adsame/文档/优酷需求/youku_pause_sql.sql");
        if (sqlFile.isFile() && sqlFile.exists()) {
            try {
                InputStreamReader read = new InputStreamReader(
                        new FileInputStream(sqlFile), encoding);
                BufferedReader bufferedReader = new BufferedReader(read);
                FileOutputStream fs = new FileOutputStream(outFile);
                FileOutputStream nfs = new FileOutputStream(newSqlFile);
                String lineTxt = null;
                PrintStream p = new PrintStream(fs);
                PrintStream p2 = new PrintStream(nfs);
                p.println("use dsp_backend;");
                while ((lineTxt = bufferedReader.readLine()) != null) {
                    String[] arr = lineTxt.split("\t");
//                	p.println("update youku_industry_floor_table set floor="
//                			+ arr[2] + " where industry=\"" + arr[0] + "\" and config=\""
//                			+ arr[1] + "\";");
                    p.println("insert into youku_industry_floor_table values (\""
                            + arr[0] + "\", \"" + arr[1] + "\", " + arr[2] + ");");
//                    p2.println(arr[0] + "\t" + arr[1] + "_6" + "\t" + arr[2]);
                }
                read.close();
                p.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}
